package com.cvv.controller;

import java.sql.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.cvv.dao.InstorageMapper;
import com.cvv.entity.Instorage;


@Controller
@RequestMapping("instroage")
public class InstorageController {
	@Autowired
    private InstorageMapper ins;
	
	@RequestMapping("getAll")
	public String getAll(Model model) {
		List<Instorage> list = ins.getAll();
		System.out.println(list);
		model.addAttribute("list",list);
		return "depot_manage/in/in_allocate";
		//depot_manage/in/in_allocate.jsp
		
	}
	
	@RequestMapping("getAllByOne/{id}")
	public String getAllByOne(Model model,@PathVariable("id") int id) {
		List<Instorage> list = ins.getAllByOne(id);
		System.out.println(list);
		model.addAttribute("list",list);
		return "depot_manage/in/in_goods";
		//depot_manage/in/in_allocate.jsp
		
	}
	
	@RequestMapping("getAllByOne/update/{id}/{num}/{time}/{remark}")
	public String update(@PathVariable("id") int id,@PathVariable("num") int num,@PathVariable("time") Date time_in,@PathVariable("remark") String remark) {
		Instorage instorage = new Instorage();
		instorage.setId(id);
		instorage.setInstodate(time_in);
		instorage.setSinstoreage(num);
		instorage.setRemark(remark);
		System.out.println(instorage);
		int num1 = ins.updateInstorage(instorage);
		System.out.println(num1);
		return "redirect:../../../../../getAll";
		//depot_manage/in/in_allocate.jsp
		
	}
	
	@RequestMapping("getAllByOneOther/{id}")
	public String getAllByOneOther(Model model,@PathVariable("id") int id) {
		List<Instorage> list = ins.getAllByOne(id);
		System.out.println(list);
		model.addAttribute("list",list);
		return "depot_manage/in/in_allocate";
		//depot_manage/in/in_allocate.jsp
		
	}
	

}
